package java6681.lesson10;



public class Counter6681Test {
    public static void main(String[] args) {
        System.out.println("countSubstring()方法测试");
        countSubstring();
        System.out.println("countChar()方法测试");
        countChar();
    }

    public static void countSubstring() {
        String[] arr = {"统计子串 子串在中间 中间有", "子串统计 子串在头尾 头尾有子串子串"
                , "不要包含要统计的子串","abc"};
        String[] arr1 = {"子串", "子串", "中间", ","};
        int[] num = {2,4,0,0};
        for (int i = 0; i < arr.length; i++) {
            System.out.println("测试用例编号：" + i);
            System.out.println("输入:" + arr[i]);
            System.out.print("预期结果:" + num[i]);
            if (Counter.count6681(arr[i], arr1[i]) == num[i]) {
                System.out.println("实际运行结果:" + Counter.count6681(arr[i], arr1[i]));
                System.out.println("通过测试");
            } else {
                System.out.println("未通过测试");
            }
            System.out.println("");
        }

    }

    public static void countChar() {
        String[] arr = {",,前面的逗号,,,连续的逗号,分割,,,后面的逗号,,"
                , ",a ,,bbb,,,ccc,", "this,java", "abc"};
        char[] arr1 = {'号', ',', 'a', 'd'};
        int[] num = {3,7,2,0};
        for (int i = 0; i < arr.length; i++) {
            System.out.println("测试用例编号：" + i);
            System.out.println("输入:" + arr[i]);
            System.out.print("预期结果:" + num[i]);
            if (Counter.count6681(arr[i], arr1[i]) == num[i]) {
                System.out.println("实际运行结果:" + Counter.count6681(arr[i], arr1[i]));
                System.out.println("通过测试");
            } else {
                System.out.println("未通过测试");
            }
            System.out.println("");
        }
    }
}
